package com.yusi.service.impl;

import com.yusi.entity.Admin;
import com.yusi.entity.Menu;
import com.yusi.mapper.MenuMapper;
import com.yusi.service.IMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yusi
 * @since 2022-01-04
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IMenuService {
    @Autowired
    private MenuMapper menuMapper;

    @Override
    public List<Menu> getMenuWithRole() {
        return menuMapper.getMenuWithRole();
    }
    @Override
    public List<Menu> getMenuByadminId() {
        //获取用户id
        Integer adminId = ((Admin) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getId();
            List<Menu> menuListFromMySQL = menuMapper.getMenuByadminId(adminId);
        return menuListFromMySQL;
    }

}
